/**
 * 
 */
package com.xpalive.domain;

import java.text.ParseException;
import java.util.Date;

import org.apache.commons.lang.StringUtils;

import com.xpalive.web.common.BaseDomain;

/**
 * @author xiongping
 * @IDE eclipse 4.3
 * @time 2015年5月21日 下午1:22:36
 */
public class Note extends BaseDomain {
	private Integer id;
	private String title;
	private Long startTime;
	private Long endTime;
	private Boolean allDay;
	private String start;
	private String end;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Long getStartTime() {
		return startTime;
	}

	public void setStartTime(Long startTime) {
		this.startTime = startTime;
	}

	public Long getEndTime() {
		return endTime;
	}

	public void setEndTime(Long endTime) {
		this.endTime = endTime;
	}

	public Boolean getAllDay() {
		return allDay;
	}

	public void setAllDay(Boolean allDay) {
		this.allDay = allDay;
	}

	public String getEnd() {
	  if(endTime == null){
      return "";
    }
		try {
			calendar.setTimeInMillis(endTime);
			return TIMESTAMPT.format(calendar.getTime());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		
	}
	public void setEnd(String end){
	  this.end = end;
    if(StringUtils.isBlank(end)){
      this.endTime =  null;
    }else{
      try {
        this.endTime = TIMESTAMP.parse(end).getTime();
      } catch (ParseException e) {
        e.printStackTrace();
      }
    }
    
  }

	public String getStart() {
	  if(startTime == null){
	    return "";
	  }
		try {
			calendar.setTimeInMillis(startTime);
			return TIMESTAMPT.format(calendar.getTime());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	public void setStart(String start){
	  this.start = start;
	  if(StringUtils.isBlank(start)){
	    this.startTime =  new Date().getTime();
	  }else{
	    try {
	      this.startTime = TIMESTAMP.parse(start).getTime();
	    } catch (ParseException e) {
	      e.printStackTrace();
	    }
	  }
	}
}
